/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.res0w.SMMS.ui.UDResource;

import java.awt.Dimension;
import java.awt.Image;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.AbstractButton;
import javax.swing.JPanel;

/**
 *
 * @author res0w
 * @since 2009-9-24
 * @version 0.3
 *
 */
public class ImagePanel extends JPanel {

    ImageBorder border = new ImageBorder();
    public ImagePanel(String imageUrl) {
        try {
            Image bg = ImageIO.read(getClass().getResource(imageUrl));
            border.setImage(bg);
            this.setBorder(border);
//            setPreferredSize(new Dimension(800, 600));
            setPreferredSize(new Dimension(bg.getWidth(null), bg.getHeight(null)));
//            btn.setLocation(108, 51);
//            setButtonLocation(btn, 106, 51);
//            btn.setBounds(108, 51, 100, 40);
            setLayout(null);
//            add(btn);
        } catch (IOException ex) {
            Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void setButtonLocation(AbstractButton ab, int x, int y) {
        int width = ab.getIcon().getIconWidth();
        int height = ab.getIcon().getIconHeight();
        ab.setBounds(x, y, width, height);
        this.add(ab);
    }
}
